#!/bin/sh

ls /sys/class/ieee80211/|while read dev
do
ssid=$(cat /tmp/sysinfo/model|cut -d" " -f2| tr a-z A-Z)_$(cat /sys/class/ieee80211/${dev}/macaddress|awk -F ":" '{print $4""$5""$6 }'| tr a-z A-Z)

uci -q batch <<-EOF >/dev/null
	set wireless.radio${dev##phy}.disabled=0
	set wireless.@wifi-device[0].txpower='20'
	set wireless.radio${dev##phy}.htmode=HT40
	set wireless.radio${dev##phy}.country=CN
	set wireless.radio${dev##phy}.noscan=1
	set wireless.@wifi-device[1].channel=161
	set wireless.@wifi-iface[${dev##phy}].ssid='$ssid'
	set wireless.@wifi-iface[${dev##phy}].key='88888888'
	set wireless.@wifi-iface[${dev##phy}].encryption='psk2'
	commit wireless
EOF
done

exit 0
